define(function(require, exports, module) {

	var $ = require('jquery');
	var List = require('../util/list');
	require('artTemplate/artTemplate/2.0.1/template.js');
	require('seajs/seajs/2.1.1/sea.js');

	exports.options = {
		listLink : '',
		listParams : '',
		pageLink : '',
		pageParams : ''
	};
	
	exports.showFinanceList = function showDepositList() {
		var depositList = new List();
		depositList.options.template = "financeList-template";
		depositList.options.container = "#financeList";
		depositList.options.links = { "list" : $CONFIG.base_url + "/api/admin/finance/list" };
		depositList.options.params = {"s":"10","p":"1"};
		depositList.load(function(){
			$("#financeList").on("click","a",function(){
				if($(this).attr('class')=='user'){					
					exports.detail($(this).attr('data'),15);
				}
				if($(this).attr('class')=='project'){
					exports.support($(this).attr('data'));
				}
			});
		});
	};
	$("#finance").click(function() {
		exports.showFinanceList();
	});
	
	exports.detail = function detail(uid,date) {
		var fundDetails = new List();
		fundDetails.options.template = "fund-table-template";
		fundDetails.options.container = "#financeList";
		fundDetails.options.links = {
			"list" : $CONFIG.base_url + '/api/fund_detail/list'
		};
		fundDetails.options.params = {
			"uid" : uid,
			"p" : 1,
			"s" : 10
		};
		fundDetails.load(
				function(){
					$(".hf").off();
					$(".hf").on("click",function(){
						$("#finance").click();
					});
				});
	};
	// 最新资助
	exports.support=function(pid){	
		var newSupport = new List();
		newSupport.options.template = "support-template";
		newSupport.options.container = "#financeList";
		newSupport.options.links = {
				"list" : $CONFIG.base_url + '/api/project/support/list'
		};
		newSupport.options.params = {
				"pid" : pid,
				"p" : 1,
				"s" : 6
		};
		newSupport.load(function(){
			$(".hf").off();
			$(".hf").on("click",function(){
				$("#finance").click();
			});
		});
	};
	
	$(document).ready(function(data) {
		$("#finance").click();
	});
});